<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkLabel extends TemplateGtkGladeWidgetCompilerBase{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sWidgetId=$oObject->getWidgetId();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled="\t\t{$sVariableName}=new {$sWidgetClass}();";
		$sLable=str_replace('"','\\"',$oObject->getProperty('label'));// 文本内容
		$sCompiled.="\t\t{$sVariableName}->set_label(\"{$sLable}\");";
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('use_markup'))){$sCompiled.="\t\t{$sVariableName}->set_use_markup(true);";}// 使用标记语言
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('use_underline'))){$sCompiled.="\t\t{$sVariableName}->set_use_underline(true);";}// 使用下划线
		if($sJustify=$oObject->getProperty('justify')){// 对齐
			$sJustify=str_replace('GTK_','Gtk::',$sJustify);
			$sCompiled.="\t\t{$sVariableName}->set_justify({$sJustify});";
		}
		if($sPattern=$oObject->getProperty('pattern')){$sCompiled.="\t\t{$sVariableName}->set_pattern('{$sPattern}');";}// 模式
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('wrap'))){$sCompiled.="\t\t{$sVariableName}->set_line_wrap(true);";}// 自动换行
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('selectable'))){$sCompiled.="\t\t{$sVariableName}->set_selectable(true);";}// 可选中
		if($sMnemonicWidget=$oObject->getProperty('mnemonic_widget')){$sCompiled.="\t\t{$sVariableName}->set_mnemonic_widget(\$this->getWidget('{$sMnemonicWidget}',\$arrObjectForSignal);\r\n";}// 可记忆窗体
		if($sEllipsize=$oObject->getProperty('ellipsize')){// 省略化
			$sEllipsize=str_replace('PANGO_','Pango::',$sEllipsize);
			$sCompiled.="\t\t{$sVariableName}->set_ellipsize({$sEllipsize});";
		}
		if($sWidthChars=$oObject->getProperty('width_chars')){$sCompiled.="\t\t{$sVariableName}->set_width_chars({$sWidthChars});";}// 字符宽度
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('single_line_mode'))){$sCompiled.="\t\t{$sVariableName}->set_single_line_mode(true);";}// 单行
		if($sAngle=$oObject->getProperty('angle')){$sCompiled.="\t\t{$sVariableName}->set_angle({$sAngle}*360);";}// 角度
		if($sMaxWidthChars=$oObject->getProperty('max_width_chars')){$sCompiled.="\t\t{$sVariableName}->set_max_width_chars({$sMaxWidthChars});";}// 最大字符宽
		$sXAlign=($sXAlign=$oObject->getProperty('xalign'))===null? '0.5': $sXAlign;// x/y Align
		$sYAlign=($sYAlign=$oObject->getProperty('yalign'))===null? '0.5': $sYAlign;
		$sCompiled.="\t\t{$sVariableName}->set_alignment({$sXAlign}, {$sYAlign});";
		$sXPad=($sXPad=$oObject->getProperty('xpad'))===null?'0':$sXPad;
		$sYPad=($sYPad=$oObject->getProperty('ypad'))===null?'0':$sYPad;// x/y Padding
		$sCompiled.="\t\t{$sVariableName}->set_padding({$sXPad}, {$sYPad});";
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
